using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using JSON;

public class JSONTower{
	#region 单例
	private static JSONTower instance;
	public static JSONTower getInstance(){
	if (instance == null)
		instance = new JSONTower ();
		return instance;
	}
	#endregion

	#region 变量
	private JSONNode json;
	private JSONNode JSONData{
		get{
			if(json == null)
				json = JsonRead.Read("JSONTower");
			return json;
		}
	}
	#endregion
	#region 外部调用
	public void Clear(){
		json = null;
	}
	public JSONNode GetJSON(string key){
		return JSONData [key];
	}
	public JSONNode GetJSON(int index){
		return JSONData [index];
	}
	/// <summary>
	/// 有多少个数据
	/// </summary>
	public int GetCount(){
	return JSONData.Count;
	}

    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListID(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetID(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 天神id
	/// </summary>
	public int GetID(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["ID"].AsInt;
		return  value;
	}
	/// <summary>
	/// 天神id :From Index
	/// </summary>
	public int GetID(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetID(index.ToString());
			return  value;
		}
		value = json["ID"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListLV(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetLV(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 等级
	/// </summary>
	public int GetLV(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["LV"].AsInt;
		return  value;
	}
	/// <summary>
	/// 等级 :From Index
	/// </summary>
	public int GetLV(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetLV(index.ToString());
			return  value;
		}
		value = json["LV"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListPrefabName(string target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetPrefabName(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 资源名
	/// </summary>
	public string GetPrefabName(string key){
		JSONNode json = GetJSON (key);
		string  value;
		value = json["PrefabName"].ToString();
		return  value;
	}
	/// <summary>
	/// 资源名 :From Index
	/// </summary>
	public string GetPrefabName(int index){
		string value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetPrefabName(index.ToString());
			return  value;
		}
		value = json["PrefabName"].ToString();
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListHP(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetHP(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 生命
	/// </summary>
	public int GetHP(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["HP"].AsInt;
		return  value;
	}
	/// <summary>
	/// 生命 :From Index
	/// </summary>
	public int GetHP(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetHP(index.ToString());
			return  value;
		}
		value = json["HP"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListAttack(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetAttack(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 攻击力（dps）
	/// </summary>
	public int GetAttack(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["Attack"].AsInt;
		return  value;
	}
	/// <summary>
	/// 攻击力（dps） :From Index
	/// </summary>
	public int GetAttack(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetAttack(index.ToString());
			return  value;
		}
		value = json["Attack"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListAttackGap(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetAttackGap(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 攻击间隔 (需转为Float/1000) 
	/// </summary>
	public int GetAttackGap(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["AttackGap"].AsInt;
		return  value;
	}
	/// <summary>
	/// 攻击间隔 (需转为Float/1000)  :From Index
	/// </summary>
	public int GetAttackGap(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetAttackGap(index.ToString());
			return  value;
		}
		value = json["AttackGap"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListMoveSpeed(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetMoveSpeed(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 移动速度 (需转为Float/1000) 
	/// </summary>
	public int GetMoveSpeed(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["MoveSpeed"].AsInt;
		return  value;
	}
	/// <summary>
	/// 移动速度 (需转为Float/1000)  :From Index
	/// </summary>
	public int GetMoveSpeed(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetMoveSpeed(index.ToString());
			return  value;
		}
		value = json["MoveSpeed"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListAttackDistance(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetAttackDistance(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 攻击距离 (需转为Float/1000) 
	/// </summary>
	public int GetAttackDistance(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["AttackDistance"].AsInt;
		return  value;
	}
	/// <summary>
	/// 攻击距离 (需转为Float/1000)  :From Index
	/// </summary>
	public int GetAttackDistance(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetAttackDistance(index.ToString());
			return  value;
		}
		value = json["AttackDistance"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListCrit(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetCrit(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 暴击率 (需转为Float/10000) 
	/// </summary>
	public int GetCrit(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["Crit"].AsInt;
		return  value;
	}
	/// <summary>
	/// 暴击率 (需转为Float/10000)  :From Index
	/// </summary>
	public int GetCrit(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetCrit(index.ToString());
			return  value;
		}
		value = json["Crit"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListCritHurt(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetCritHurt(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 暴击伤害 (需转为Float/10000) 
	/// </summary>
	public int GetCritHurt(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["CritHurt"].AsInt;
		return  value;
	}
	/// <summary>
	/// 暴击伤害 (需转为Float/10000)  :From Index
	/// </summary>
	public int GetCritHurt(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetCritHurt(index.ToString());
			return  value;
		}
		value = json["CritHurt"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListStartPower(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetStartPower(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 初始神力点
	/// </summary>
	public int GetStartPower(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["StartPower"].AsInt;
		return  value;
	}
	/// <summary>
	/// 初始神力点 :From Index
	/// </summary>
	public int GetStartPower(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetStartPower(index.ToString());
			return  value;
		}
		value = json["StartPower"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListPowerMax(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetPowerMax(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 神力点上限
	/// </summary>
	public int GetPowerMax(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["PowerMax"].AsInt;
		return  value;
	}
	/// <summary>
	/// 神力点上限 :From Index
	/// </summary>
	public int GetPowerMax(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetPowerMax(index.ToString());
			return  value;
		}
		value = json["PowerMax"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListPowerRecovery(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetPowerRecovery(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 神力回复速度 (以秒为单位) 
	/// </summary>
	public int GetPowerRecovery(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["PowerRecovery"].AsInt;
		return  value;
	}
	/// <summary>
	/// 神力回复速度 (以秒为单位)  :From Index
	/// </summary>
	public int GetPowerRecovery(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetPowerRecovery(index.ToString());
			return  value;
		}
		value = json["PowerRecovery"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListAvailableAttackCount(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetAvailableAttackCount(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 攻击次数
	/// </summary>
	public int GetAvailableAttackCount(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["AvailableAttackCount"].AsInt;
		return  value;
	}
	/// <summary>
	/// 攻击次数 :From Index
	/// </summary>
	public int GetAvailableAttackCount(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetAvailableAttackCount(index.ToString());
			return  value;
		}
		value = json["AvailableAttackCount"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListHitEffect(string target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetHitEffect(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 受击特效
	/// </summary>
	public string GetHitEffect(string key){
		JSONNode json = GetJSON (key);
		string  value;
		value = json["HitEffect"].ToString();
		return  value;
	}
	/// <summary>
	/// 受击特效 :From Index
	/// </summary>
	public string GetHitEffect(int index){
		string value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetHitEffect(index.ToString());
			return  value;
		}
		value = json["HitEffect"].ToString();
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListDieEffect(string target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetDieEffect(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 死亡特效
	/// </summary>
	public string GetDieEffect(string key){
		JSONNode json = GetJSON (key);
		string  value;
		value = json["DieEffect"].ToString();
		return  value;
	}
	/// <summary>
	/// 死亡特效 :From Index
	/// </summary>
	public string GetDieEffect(int index){
		string value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetDieEffect(index.ToString());
			return  value;
		}
		value = json["DieEffect"].ToString();
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListAttackSkillID(int target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetAttackSkillID(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 攻击使用的技能
	/// </summary>
	public int GetAttackSkillID(string key){
		JSONNode json = GetJSON (key);
		int  value;
		value = json["AttackSkillID"].AsInt;
		return  value;
	}
	/// <summary>
	/// 攻击使用的技能 :From Index
	/// </summary>
	public int GetAttackSkillID(int index){
		int value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetAttackSkillID(index.ToString());
			return  value;
		}
		value = json["AttackSkillID"].AsInt;
		return  value;
	}
    /// <summary>
	/// GetJSONNodeList Like Target
	/// </summary>
	public int[] GetListBaseAniSpeed(float target){
		List<int> list = new List<int>();
		for (int i = 0; i < GetCount(); i++) {
			if( GetBaseAniSpeed(i) == target)
				list.Add(i);
		}
		return list.ToArray();
	}
	/// <summary>
	/// 移动动画速度 (需转为Float/10000) 
	/// </summary>
	public float GetBaseAniSpeed(string key){
		JSONNode json = GetJSON (key);
		float  value;
		value = json["BaseAniSpeed"].AsFloat;
		return  value;
	}
	/// <summary>
	/// 移动动画速度 (需转为Float/10000)  :From Index
	/// </summary>
	public float GetBaseAniSpeed(int index){
		float value;
		JSONNode json = GetJSON (index);
		if(json == null){
			value = GetBaseAniSpeed(index.ToString());
			return  value;
		}
		value = json["BaseAniSpeed"].AsFloat;
		return  value;
	}

	#endregion
}